package com.itheima.test;

import java.util.ArrayList;
import java.util.Scanner;

/*
【代码题】有一个已经排好序的列表[1, 8, 26, 45, 60, 78, 99], 
现在输入一个0-100之间（范围无需代码判断）的数字, 将该数字按从小到大顺序插入该列表。
(如输入数字50, 那么这个列表的结果为：[1, 8, 26, 45, 50, 60, 78, 99]。)请在控制台中打印插入前和插入后的数组
 */
public class HasStatic {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr1 = {1, 8, 26, 45, 60, 78, 99};
        int[] arr2 = new int[arr1.length + 1];

        int input = sc.nextInt();

        int index = -1;

        for (int i = 0; i < arr1.length; i++) {
            //arr1[i]
            if (arr1[i] >= input) {
                index = i;
                break;
            }
        }


        for (int i = 0; i < arr1.length; i++) {
            //arr1[i]
            if (arr1[i] < input) {
                arr2[i] = arr1[i];
            } else if (i == index) {
                arr2[i] = input;
                arr2[i+1]= arr1[i];
            } else {
                arr2[i + 1] = arr1[i];
            }
        }


        for (int i : arr1) {
            System.out.print(i+" ");
        }
        System.out.println();
        for (int i = 0; i < arr2.length; i++) {
            //arr2[i]
            System.out.print(arr2[i] + " ");
        }


    }


}
